<template>

  <!--
   日期选择器:
    type: 'datePicker'
    itemType:      element原生type,默认date（date,week，month，year）
    format:        自定义显示与返回的日期格式
    pickerOptions: elementUi原生picker-options
    placeholder:   日期选择框占位文本
-->
  <el-date-picker
    v-model="currentData"
    :type="itemType"
    :format="format"
    :value-format="format"
    :picker-options="pickerOptions"
    :placeholder="booleanFun(readonly)?'': placeholder || `请选择${label}`"
    :disabled="booleanFun(disabled)"
    :readonly="booleanFun(readonly)"
    :clearable="clearable"
    :style="{width}"
    size="mini"
  />

</template>

<script>
import {booleanFun, currentData} from '@/components/FlyElement/common'

export default {
  name: 'ADatePicker',
  props: {
    prop: {
      type: String,
      required: true
    },
    label: {
      type: String,
      required: true
    },
    data: {
      type: String | Number
    },
    itemType: {
      type: String,
      default: 'date'
    },
    format: {
      type: String,
      default: 'yyyy-MM-dd'
    },
    pickerOptions: {
      type: Object
    },
    placeholder: {
      type: String
    },
    width: {
      type: String,
      default: '100%'
    },
    readonly: {
      type: Boolean | Function,
      default: false
    },
    disabled: {
      type: Boolean | Function,
      default: false
    },
    clearable: {
      type: Boolean
    }
  },
  computed: {
    currentData
  },
  methods: {
    booleanFun
  }
}
</script>
